package com.shyfu.services;

import com.shyfu.dao.AuthorDAO;
import com.shyfu.entities.Author;
import com.shyfu.entities.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Svitlana on 04-Apr-14.
 */
@Service
public class AuthorServiceImpl implements AuthorService {

    @Autowired
    private AuthorDAO authorDAO;

    @Override
    @Transactional
    public void addAuthor(Author author) {
        authorDAO.addAuthor(author);
    }

    @Override
    @Transactional
    public void removeAuthor(Author author) {
        authorDAO.removeAuthor(author);
    }

    @Override
    @Transactional
    public List<Author> getAllAuthors() {
        return authorDAO.getAllAuthors();
    }

    @Override
    @Transactional
    public Author getAuthor(long id) {
        return authorDAO.getAuthor(id);
    }

    @Override
    @Transactional
    public void removeAuthor(long id) {
        authorDAO.removeAuthor(id);
    }

    @Override
    @Transactional
    public void updateBook(Book book) {
        authorDAO.updateBook(book);
    }
}
